package com.yc.bbs.dao;

import com.yc.bbs.entity.Board;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * BBS论坛-板块表-13 Mapper 接口
 * </p>
 *
 * @author ly
 * @since 2024-11-23
 */
public interface BoardMapper extends BaseMapper<Board> {

    @Select("select * from tbl_board where parentid=#{pid}")
    // @Results => <ResultMap>
    @Results(
            id = "rm1",
            value = {@Result(column = "id", property = "id", id = true),
                    @Result(column = "parentid", property = "parentid"),
                    @Result(column = "id", property = "children",
                        many = @Many(select = "selectByPid"))}
    )
    public List<Board> selectByPid(int pid);

}
